﻿@using KRM.Core
@model List<KRM.Core.vLoadPlanningOrderItem>
@{
    var superSavers = tblCompanyVariable.ListSuperSaverProductId;
    var db = new KRMEntities();
}
<script>
    $(document).ready(function() {
        $(".datatable-fix").dataTable({
            "iDisplayLength": 10000,
            "sScrollY": $(".datatable-fix").attr("data-height"),
            "sScrollX": "100%",
            "aaSorting": []
        });
        $('.dataTables_paginate').remove();
        InitTableSelected();
    });
    
</script>
<style>
    .bgGreenYellow td{background: GreenYellow}
    .bgPowder td{background: PowderBlue}
</style>
<table class="table table-bordered table-fix datatable-fix tbl-selected" data-height="200">
    <thead>
        <tr>
            <th>Warning</th>
            <th>Assembly</th>
            <th>DeliveryDate</th>
            <th>OrderRef</th>
            <th>PostCode</th>
            <th>Product</th>
            <th>Qty</th>
            <th>Special Instructions</th>
            <th>Weight</th>
            <th>Packages</th>
            <th>Customer</th>
            <th>Address</th>
            <th>Email</th>
            <th>DatePlaced</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            var color = "";
            var bg = "";
            if (item.ItemStatusID == LpLoadItemStatusExtension.StatusId(LoadItemStatus.REPLAN))
            {
                color = "style=color:red";
            }
            if (superSavers.Contains(item.ProductID))
            {
                bg = "bgGreenYellow";
            }
            if (db.tblKRMSentStocks.Count(a => a.OrderRef == item.OrderRef && a.PartID == 17488) > 0)
            {
                bg = "bgPowder";
            }
            <tr @color class="@bg" data-id="@item.OrderItemID" onclick="setmovecarrier(@item.WarehouseID,@item.OrderItemID,@item.carrierID)">
                <td style="text-align: center">
                    @if (item.ParagonVisitID != null && item.ParagonVisitID > 0)
                    {
                        <img src="/img/Load/Paragon20.png" alt="" title="Order in paragon with paragon visit id @item.ParagonVisitID"/>
                    }
                    else if (item.NumOfWarehouse > 1 || item.NumOfCarriers > 1)
                    {
                        <img src="/img/Load/Symbol-alert.png" alt="" title="No of warehouse: @item.NumOfWarehouse \nNo of Carriers: @item.NumOfCarriers"/>
                    }
                </td>
                <td style="text-align: center">
                </td>
                <td>@item.DeliveryDate</td>
                <td>@item.OrderRef</td>
                <td>@item.Postcode</td>
                <td>@item.Product</td>
                <td>@item.Qty</td>
                <td>@item.SpecialInstructions</td>
                <td>@item.WeightKG</td>
                <td>@item.Packages</td>
                <td>@item.Customer</td>
                <td>@item.Address</td>
                <td>@item.EmailAddress</td>
                <td>@item.DatePlaced</td>
            </tr>
        }
    </tbody>
</table>
